package vn.com.fsoft.model.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;

@Entity
@Table(name="TOWN")
public class Town implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7236968547683072499L;
	private int townId;
	private String townName;
	private County countyTown;
	private Set<Address> listAddress = new HashSet<Address>(0);
	
	public Town(){
		super();
	}
	
	public Town(int townId, String townName, County countyTown,
			Set<Address> listAddress) {
		super();
		this.townId = townId;
		this.townName = townName;
		this.countyTown = countyTown;
		this.listAddress = listAddress;
	}
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="TOWN_ID",unique=true,nullable=false)
	public int getTownId() {
		return townId;
	}
	public void setTownId(int townId) {
		this.townId = townId;
	}
	@Column(name="TOWN_NAME",length=30)
	public String getTownName() {
		return townName;
	}
	public void setTownName(String townName) {
		this.townName = townName;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "COUNTY_ID", nullable = false)
	public County getCountyTown() {
		return countyTown;
	}
	public void setCountyTown(County countyTown) {
		this.countyTown = countyTown;
	}
	@OneToMany(fetch = FetchType.LAZY,mappedBy = "townAddress")
	public Set<Address> getListAddress() {
		return listAddress;
	}
	public void setListAddress(Set<Address> listAddress) {
		this.listAddress = listAddress;
	}
	
}
